import { ElMessageBox } from 'element-plus'

const Fn = {

    // 用于包装需要二次确认的函数执行 ,msg:弹窗内容，title:弹窗标题, cancelFn: 取消或关闭弹窗执行的方法
    Confirm: (fn, msg, title, cancelFn) => {
        return function() {
            msg = msg || '确定？'
            title = title || '提示'
            ElMessageBox.confirm(msg, title, {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                dangerouslyUseHTMLString: true
            }).then(() => {
                const args = arguments
                fn.apply(this, args)
            }).catch(() => {
                cancelFn && cancelFn();
            })
        }
    }
}

export default Fn
